<template>
  <div v-if="one!=0">
    <my-header></my-header>
    <div class="bang">
     <span @click="bangone">日榜TOP4</span> 
     <span @click="bangtwo">周榜TOP4</span> 
     <span @click="bangthree">月榜TOP4</span> 
    </div>
    <div class="container">
      
      <div class="box one">
        <div class="box-top">
          <img src="/img/ranking/no1.png" alt="" />
        </div>
        <div class="box-bottom">
          <div class="box-bottom-img">
            <router-link :to="`/detail/${one[0].id}`">
            <img :src="one[0].img_small" alt="" />
            </router-link>
          </div>

          <div class="box-bottom-text">
            <div>{{one[0].title}}</div>
            <div style="display:flex;">
              <el-rate
              v-model="value"
              disabled
              text-color="#ff9900"
            >
            </el-rate>
            <span style="margin:-4px 0 0 10px;">100%推荐</span>
            </div>
            <div>
              作者:<span>{{one[0].author}}</span>
            </div>
            <div>
              <span style="color:red;font-weight:bold;">¥{{one[0].price}}</span>
            </div>
            <div class="goumai">
              <button>立即购买</button>
              <button @click="add">仔细看看</button>
            </div>
          </div>
        </div>
      </div>
      <div class="box two">
        <div class="box-top">
          <img src="/img/ranking/no2.png" alt="" />
        </div>
        <div class="box-bottom">
          <div class="box-bottom-img">
            <router-link :to="`/detail/${one[1].id}`">
            <img :src="one[1].img_small" alt="" />
            </router-link>
          </div>
          <div class="box-bottom-text">
            <div>{{one[1].title}}</div>
            <div style="display:flex;">
              <el-rate
              v-model="value"
              disabled
              text-color="#ff9900"
            >
            </el-rate>
            <span style="margin:-4px 0 0 10px;">100%推荐</span>
            </div>
            <div>
              作者:<span>{{one[1].author}}</span>
            </div>
            <div>
              <span style="color:red;font-weight:bold;">¥{{one[1].price}}</span>
            </div>
            <div class="goumai">
              <button>立即购买</button>
              <button @click="addone">仔细看看</button>
            </div>
          </div>
        </div>
      </div>
      <div class="box three">
        <div class="box-top">
          <img src="/img/ranking/no3.png" alt="" />
        </div>
        <div class="box-bottom">
          <div class="box-bottom-img">
            <router-link :to="`/detail/${one[2].id}`">
            <img :src="one[2].img_small" alt="" />
            </router-link>
          </div>
          <div class="box-bottom-text">
            <div>{{one[2].title}}</div>
            <div style="display:flex;">
              <el-rate
              v-model="value"
              disabled
              text-color="#ff9900"
            >
            </el-rate>
            <span style="margin:-4px 0 0 10px;">100%推荐</span>
            </div>
            <div>
              作者:<span>{{one[2].author}}</span>
            </div>
            <div>
              <span style="color:red;font-weight:bold;">¥{{one[2].price}}</span>
            </div>
            <div class="goumai">
              <button>立即购买</button>
              <button @click="addtwo">仔细看看</button>
            </div>
          </div>
        </div>
      </div>
      <div class="box four">
        <div class="box-top">
          <img src="/img/ranking/no3.png" alt="" />
        </div>
        <div class="box-bottom">
          <div class="box-bottom-img">
            <router-link :to="`/detail/${one[3].id}`">
            <img :src="one[3].img_small" alt="" />
            </router-link>
          </div>
          <div class="box-bottom-text">
            <div>{{one[3].title}}</div>
            <div style="display:flex;">
              <el-rate
              v-model="value"
              disabled
              text-color="#ff9900"
            >
            </el-rate>
            <span style="margin:-4px 0 0 10px;">100%推荐</span>
            </div>
            <div>
              作者:<span>{{one[3].author}}</span>
            </div>
            <div>
              <span style="color:red;font-weight:bold;">¥{{one[3].price}}</span>
            </div>
            <div class="goumai">
              <button>立即购买</button>
              <button @click="addthree">仔细看看</button>
            </div>
          </div>
        </div>
      </div>
    </div>
    <my-footer style="margin-top:30px"></my-footer>
  </div>
</template>
<script>
export default {
  data() {
    return {
      value: 5,
      one: [],
    };
  },
  mounted() {
    this.axios.get("/bookbang?bang_id=1").then((result) => {
      this.one = result.data;
    });
  },
  methods: {
    bangone() {
      this.axios.get("/bookbang?bang_id=1").then((result) => {
        this.one = result.data;
      });
    },
    bangtwo() {
      this.axios.get("/bookbang?bang_id=2").then((result) => {
        this.one = result.data;
      });
    },
    bangthree() {
      this.axios.get("/bookbang?bang_id=3").then((result) => {
        this.one = result.data;
      });
    },
    add(){
      this.$router.push(`/detail/${this.one[0].id}`)
    },
    addone(){
      this.$router.push(`/detail/${this.one[1].id}`)
    },
    addtwo(){
      this.$router.push(`/detail/${this.one[2].id}`)
    },
    addthree(){
      this.$router.push(`/detail/${this.one[3].id}`)
    }
  },
};
</script>
<style scoped>
.container {
  max-width: 1200px;
  min-width: 1200px;
  margin: auto;
  display: flex;
  flex-wrap: wrap;
}
.bang {
  max-width: 1200px;
  min-width: 1200px;
  margin: auto;
  color: #f57921;
  font-size: 26px;
  font-weight: bolder;
  text-align: left;
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
}
.bang span:hover {
  cursor: pointer;
}
.container .box {
  width: 590px;
  height: 300px;
  text-align: left;
}
.container .box:hover {
  background-color: #e6e6e6;
}
.container .one {
  border-bottom: 1px solid #ccc;
  border-right: 1px solid #ccc;
  border-top: 1px solid #ccc;
}
.container .two {
  border-bottom: 1px solid #ccc;
  border-top: 1px solid #ccc;
}
.container .three {
  border-bottom: 1px solid #ccc;
  border-right: 1px solid #ccc;
}
.container .four {
  border-bottom: 1px solid #ccc;
}
.container .box-top > img {
  width: 30px;
  margin: 10px 0 0 20px;
}
.container .box-bottom {
  margin-left: 20px;
  margin-top: 10px;
  display: flex;
}
.container .box-bottom-img {
  width: 200px;
  border: 1px solid red;
}
.container .box-bottom-img img {
  width: 100%;
}
.container .box-bottom-text {
  line-height: 30px;
  margin-left: 50px;
}
.container .box-bottom-text .goumai > button {
  width: 100px;
  height: 40px;
  border: 0;
  color: red;
  background-color: rgb(255, 237, 237);
  margin: 20px 20px 0 0;
}
</style>